/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package eistar.impl;

import eistar.EistarPackage;
import eistar.Entity;
import eistar.TeraryRelation;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Terary Relation</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link eistar.impl.TeraryRelationImpl#getMiddle <em>Middle</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class TeraryRelationImpl extends RelationImpl implements TeraryRelation {
	/**
	 * The cached value of the '{@link #getMiddle() <em>Middle</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMiddle()
	 * @generated
	 * @ordered
	 */
	protected Entity middle;
	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected TeraryRelationImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return EistarPackage.Literals.TERARY_RELATION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Entity getMiddle() {
		if (middle != null && middle.eIsProxy()) {
			InternalEObject oldMiddle = (InternalEObject)middle;
			middle = (Entity)eResolveProxy(oldMiddle);
			if (middle != oldMiddle) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, EistarPackage.TERARY_RELATION__MIDDLE, oldMiddle, middle));
			}
		}
		return middle;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Entity basicGetMiddle() {
		return middle;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMiddle(Entity newMiddle) {
		Entity oldMiddle = middle;
		middle = newMiddle;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, EistarPackage.TERARY_RELATION__MIDDLE, oldMiddle, middle));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case EistarPackage.TERARY_RELATION__MIDDLE:
				if (resolve) return getMiddle();
				return basicGetMiddle();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case EistarPackage.TERARY_RELATION__MIDDLE:
				setMiddle((Entity)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case EistarPackage.TERARY_RELATION__MIDDLE:
				setMiddle((Entity)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case EistarPackage.TERARY_RELATION__MIDDLE:
				return middle != null;
		}
		return super.eIsSet(featureID);
	}

} //TeraryRelationImpl
